package es.udc.fic.hamNeggs.dao;

import es.udc.fic.hamNeggs.manager.UserStoriesManager;
import es.udc.fic.hamNeggs.pojo.UserStoriesComment;

public class InputComment {
    private String id;

    private String parent;

    private String comment;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public UserStoriesComment toUserStoriesComment() {
        UserStoriesComment cmt = new UserStoriesComment();
        UserStoriesManager ustmng = new UserStoriesManager();

        if (id == null && id != "")
            cmt.setId(new Long(id));
        if (comment != null && comment != "")
            cmt.setComment(comment);
        if (parent != null && parent != "")
            cmt.setUserStories(ustmng.getUserStories(new Long(parent)));

        ustmng.close();
        return cmt;
    }

    public void setUserStoriesComment(UserStoriesComment ustcmt) {
        if (ustcmt.getId() != null)
            id = ustcmt.getId().toString();
        if (ustcmt.getComment() != null)
            comment = ustcmt.getComment();
        if (ustcmt.getUserStories() != null)
            parent = ustcmt.getUserStories().getId().toString();
    }

}
